package com.zx.mes.hyl.singleton;

import lombok.extern.slf4j.Slf4j;

/**
 * 静态内部类测试
 *
 * @author 华云龙
 * @date 2018-9-19
 */
@Slf4j
public class StaticInnerSingleton {

    /**
     * 私有方法不允许实例化
     */
    private StaticInnerSingleton(){
        log.info("空参实例化");
    }

    {
        log.info("一般代码块");
    }

    static {
        log.info("静态代码块");
    }

    private static class InnerSingleton{
        {
            log.info("内部类代码块初使化");
        }
        private static StaticInnerSingleton staticInnerSingleton = new StaticInnerSingleton();
    }

    public static StaticInnerSingleton getInstance(){
        return InnerSingleton.staticInnerSingleton;
    }
}


